﻿
/// <summary>
/// 零食工厂基类，负责零食原料采购，加工，包装流程
/// </summary>
public class SnackFactoryBase
{
    // 各个流程的供应厂
    protected AbsRawMaterialFactoryBase rawMaterialFactory;
    protected AbsSeasoningFactoryBase seasoningFactory;
    protected AbsPackingFactoryBase packingFactory;
    
    // 选择原料供应厂
    public void SetRawMaterialFactory(AbsRawMaterialFactoryBase rawMaterialFactory)
    {
        this.rawMaterialFactory = rawMaterialFactory;
    }
    
    // 选择调味供应厂
    public void SetSeasoningFactory(AbsSeasoningFactoryBase seasoningFactory)
    {
        this.seasoningFactory = seasoningFactory;
    }
    
    // 选择包装供应厂
    public void SetPackingFactoryFactory(AbsPackingFactoryBase packingFactory)
    {
        this.packingFactory = packingFactory;
    }
    
    // 获取一个零食
    public Snack CreateSnack(string snackName)
    {
        Snack snack = new Snack();
        snack.SetName(snackName);
        // 加工流程
        // 先采购原料（不可跳过）
        rawMaterialFactory.SetRawMaterial(snack);
        // 调味
        SeasoningProgress(snack);
        // 包装
        PackingProgress(snack);
        
        return snack;
    }

    // 调味进程
    protected virtual void SeasoningProgress(Snack snack)
    {
        seasoningFactory.SeasoningSnack(snack);
    }
    
    // 包装进程
    protected virtual void PackingProgress(Snack snack)
    {
        packingFactory.PackingSnack(snack);
    }

}

// 零食
public class Snack
{
    
    public string SnackName;
    
    public string SnackDesc;

    public void SetName(string snackName)
    {
        this.SnackName = snackName;
    }

    public void AddDescription(string snackDesc)
    {
        SnackDesc = $"{SnackDesc}|{snackDesc}";
    }
}





